<?php

class B2b_Widgets_Homeprofessions_Widget extends Tomato_Widget
{
    protected function _prepareShow()
    {	
		$path_data 		   = 'application/modules/b2b/widgets/data';
		require_once 	   $path_data.'/mainpageXML.php';
		$path_xml_mainpage = $path_data . '/mainpage.xml';
		$mainpageObj = new mainpageXML($path_xml_mainpage);	
		$this->_view->assign("professions",$mainpageObj->getProfessions());
		
		
		$request = Zend_Controller_Front::getInstance()->getRequest();
        $lang = $request->getParam('lang');
        $this->_view->assign('lang', $lang);
        
        $conn = Tomato_Db_Connection::factory()->getMasterConnection();
        
        $enterpriseDao = Tomato_Model_Dao_Factory::getInstance()->setModule('enterprise')->getEnterpriseDao();
        $enterpriseDao->setDbConnection($conn);
		
		$arr = $mainpageObj->getProfessions();		
		$arrProfession = array();
		foreach($arr as $key=>$info)
		{
			$arrEnterprise = array();
			foreach ($info['enterprise'] as $e_id){
				$enterprise = $enterpriseDao->getById($e_id);
				$arrEnterprise[] = $enterprise;
			}
			$arrProfession[$key] = 	$arrEnterprise;
		}		
		$this->_view->assign('arrProfession', $arrProfession);		
    }

    protected function _prepareConfig()
    {					
    }
}
